Ext.define('XS.controller.Staff',{
	extend:	'Ext.app.Controller',
	views:	['staff.List','staff.Edit'],
	stores:	['Staff'],
	models:	['Staff'],
	init:	function(){
		this.control({
			'stafflist':{
				itemdblclick: this.editStaff
			},
			'staffedit button[action=save]':{
				click:this.updateStaff
			}
		});
	},
	editStaff:function(grid, record){
		var view = Ext.widget('staffedit');
		view.down('form').loadRecord(record);
	},
	updateStaff:function(button){
		var win = button.up('window'),
			form= win.down('form'),
			record = form.getRecord(),
			values = form.getValues();
		
		record.set(values);
		win.close();
		
		this.getStaffStore().sync();
	}
});